Ext.define('Admin.view.trade.ContractPlanListdetail', {
    extend : 'Admin.form.DetailForm',
    alias : 'widget.contractplanlistdetail',
    id:'contractplanlistdetail',
    width:1300,
    height:600,
    controller:'contractplanlist',
    renderTo: Ext.getBody(),
    title: '',
    scrollable:true,
	items:[
	       {
	    	xtype:'xform',
	    	text : '基础信息',
	    	layout: 'column',
	    	items:[//组件开始
	                {
	                    columnWidth: .2,
	                    layout: 'form',
	                    border: false,
	                    items: [{
	                    	xtype:'treepicker',
	                        name: 'tradeTime',
	                        displayField: 'text',
	                        anchor: '90%',
	                        emptyText: '交易时间',
	                        labelAlign: 'right',
	                       // containerScroll: true,
	                        animate:true,
	                        autoScroll:true,
	                        forceSelection : true,// 只能选择下拉框里面的内容
	                        rootVisible: false,                   // 这儿设置没用，需要源文件TreePicker.js中修改属性
	                        store:new Ext.data.TreeStore({
	                            fields: ['id','text'],
	                        	root : {
	                		        id : 1,
	                		        text : '交易时间',
	                		        level : "TradeWay",
	                		        leaf : false,
	                		        expanded: true
	                	        },
	                	        listeners : {
	                		        'beforeload' : function(store, operation, eOpts) {
	                			        var data = operation.node.data, params = {
	                				        id : data.id,
	                				        level : data.level
	                			        };
	                			        var parent = operation.node.parentNode;
	                			        if (parent) {
	                				        params = Ext.apply(params, {
	                					                parent : parent.data.id,
	                					                level : "TradeWay"
	                				                });
	                			        }
	                			        Ext.apply(store.proxy.extraParams, params);
	                		        }
	                	        },
							
						        proxy : {
							        type : 'api',
							        url : 'rest/api/tree/sec'
						        }

	                        })

	                    }]
	                } //组件结束
										, 
										  {
						                    columnWidth: .2,
						                    layout: 'form',
						                    border: false,
						                    items: [{
						                    	xtype:'treepicker',
						                        name: 'tradeWay',
						                        displayField: 'text',
						                        anchor: '90%',
						                        emptyText: '交易方式',
						                        labelAlign: 'right',
						                       // containerScroll: true,
						                        animate:true,
						                        autoScroll:true,
						                        forceSelection : true,// 只能选择下拉框里面的内容
						                       rootVisible: false,                   // 这儿设置没用，需要源文件TreePicker.js中修改属性
						                        store:new Admin.store.NaviTreeStore({
						                            fields: ['id','text'],
						                        	root : {
						                		        id : 2,
						                		        text : '交易方式',
						                		        level : "TradeWay",
						                		        leaf : false,
						                		        expanded: true
						                	        },
						                	        listeners : {
						                		        'beforeload' : function(store, operation, eOpts) {
						                			        var data = operation.node.data, params = {
						                				        id : data.id,
						                				        level : data.level
						                			        };
						                			        var parent = operation.node.parentNode;
									    			        if (parent) {
									    				        params = Ext.apply(params, {
									    				            parent : parent.data.id,
				                					                level : "TradeWay"
									    				                });
									    			        }
						                			        Ext.apply(store.proxy.extraParams, params);
						                		        }
						                	        },
												
											        proxy : {
												        type : 'api',
												        url : 'rest/api/tree/sec'
											        }
					
						                        })
					
						                    }]
						                } //组件结束
										,
										{
									        columnWidth: .2,
									        layout: 'form',
									        border: false,
									        items: [{
									        	xtype:'treepicker',
									            name: 'electricityType',
									            displayField: 'text',
									            anchor: '90%',
									            emptyText: '电量类型..',
									            labelAlign: 'right',
									           // containerScroll: true,
									            animate:true,
									            autoScroll:true,
									            forceSelection : true,// 只能选择下拉框里面的内容
									           rootVisible: false,                   // 这儿设置没用，需要源文件TreePicker.js中修改属性
									            store:new Admin.store.NaviTreeStore({
									                fields: ['id','text'],
									            	root : {
									    		        id : 4,
									    		        text : '电量类型',
									    		        level : "TradeWay",
									    		        leaf : false,
									    		        expanded: true
									    	        },
									    	        listeners : {
									    		        'beforeload' : function(store, operation, eOpts) {
									    			        var data = operation.node.data, params = {
									    				        id : data.id,
									    				        level : data.level
									    			        };
									    			        var parent = operation.node.parentNode;
									    			        if (parent) {
									    				        params = Ext.apply(params, {
											    				            parent : parent.data.id,
						                					                level : "TradeWay"
									    				                });
									    			        }
									    			        Ext.apply(store.proxy.extraParams, params);
									    		        }
									    	        },
												
											        proxy : {
												        type : 'api',
												        url : 'rest/api/tree/sec'
											        }
									
									            })
									
									        }]
									    } //组件结束
										,
										//组件开始
										{
											columnWidth: .13,
											margin:'10px',
											xtype:'button',
											ui : 'soft-green',
											tooltip : '新建一条合同计划',
											iconCls : 'x-fa fa-plus-square fa-lg',
											text: "添加合同计划",
											handler: function(btn){
												var win = btn.ownerCt.ownerCt.ownerCt;
												var viewModel = win.getViewModel();
												var record = viewModel.get('record');
												var org = record.get('market');
												   var simple=btn.ownerCt.ownerCt;
												   var simple1 = simple.items.items[1];
										            //添加新的fieldSet
										            var org_fieldSet = new  Ext.form.FormPanel({ 
										                //column布局控件开始         
										                layout: 'column',
										                border: false,
										                items: [
																		  {
															                columnWidth: .2,
															                layout: 'form',
															                border: false,
															                items: [{
															                	xtype:'treepicker',
															                    name: 'tradeVariety',
															                    displayField: 'text',
															                    anchor: '90%',
															                    emptyText: '交易品种..',
															                    labelAlign: 'right',
															                   // containerScroll: true,
															                    animate:true,
															                    autoScroll:true,
															                    forceSelection : true,// 只能选择下拉框里面的内容
															                   rootVisible: false,                   // 这儿设置没用，需要源文件TreePicker.js中修改属性
															                    store:new Admin.store.NaviTreeStore({
															                        fields: ['id','text'],
															                    	root : {
															            		        id : 3,
															            		        text : '交易品种',
															            		        level : "TradeWay",
															            		        leaf : false,
															            		        expanded: true
															            	        },
															            	        listeners : {
															            		        'beforeload' : function(store, operation, eOpts) {
															            			        var data = operation.node.data, params = {
															            				        id : data.id,
															            				        level : data.level
															            			        };
															            			        var parent = operation.node.parentNode;
															            			        if (parent) {
															            				        params = Ext.apply(params, {
																            				            parent : parent.data.id,
													                					                level : "TradeWay"
															            				                });
															            			        }
															            			        Ext.apply(store.proxy.extraParams, params);
															            		        }
															            	        },
																				
																			        proxy : {
																				        type : 'api',
																				        url : 'rest/api/tree/sec'
																			        }
															
															                    })
															
															                }]
															            } //组件结束
																, 
																  
															  {
														        columnWidth: .2,
														        layout: 'form',
														        border: false,
														        items: [{
														        	xtype:'treepicker',
														            name: 'tradeArea',
														            displayField: 'text',
														            anchor: '90%',
														            emptyText: '交易区域..',
														            labelAlign: 'right',
														           // containerScroll: true,
														            animate:true,
														            autoScroll:true,
														            forceSelection : true,// 只能选择下拉框里面的内容
														           rootVisible: false,                   // 这儿设置没用，需要源文件TreePicker.js中修改属性
														            store:new Admin.store.NaviTreeStore({
														                fields: ['id','text'],
														            	root : {
														    		        id : 5,
														    		        text : '交易区域',
														    		        level : "TradeWay",
														    		        leaf : false,
														    		        expanded: true
														    	        },
														    	        listeners : {
														    		        'beforeload' : function(store, operation, eOpts) {
														    			        var data = operation.node.data, params = {
														    				        id : data.id,
														    				        level : data.level
														    			        };
														    			        var parent = operation.node.parentNode;
														    			        if (parent) {
														    				        params = Ext.apply(params, {
														    				            parent : parent.data.id,
									                					                level : "TradeWay"
														    				                });
														    			        }
														    			        Ext.apply(store.proxy.extraParams, params);
														    		        }
														    	        },
																	
																        proxy : {
																	        type : 'api',
																	        url : 'rest/api/tree/sec'
																        }
														
														            })
														
														        }]
														    } //组件结束
														,
//														  {
//													        columnWidth: .2,
//													        layout: 'form',
//													        border: false,
//													        items: [Ext.create('Ext.ux.TreePicker',{
//													            name: 'deptparentname',
//													            displayField: 'text',
//													            anchor: '90%',
//													            emptyText: '合同客户..',
//													            labelAlign: 'right',
//													           // containerScroll: true,
//													            animate:true,
//													            autoScroll:true,
//													            forceSelection : true,// 只能选择下拉框里面的内容
//													           rootVisible: false,                   // 这儿设置没用，需要源文件TreePicker.js中修改属性
//													            store:new Admin.store.NaviTreeStore({
//													                fields: ['id','text'],
//													            	root : {
//													    		        id : 1,
//													    		        text : '合同客户',
//													    		        level : "TradeWay",
//													    		        leaf : false,
//													    		        expanded: true
//													    	        },
//													    	        listeners : {
//													    		        'beforeload' : function(store, operation, eOpts) {
//													    			        var data = operation.node.data, params = {
//													    				        id : data.id,
//													    				        level : data.level
//													    			        };
//													    			        var parent = operation.node.parentNode;
//													    			        if (parent) {
//													    				        params = Ext.apply(params, {
//													    					                parent : parent.data.id
//													    				                });
//													    			        }
//													    			        Ext.apply(store.proxy.extraParams, params);
//													    		        }
//													    	        },
//																
//															        proxy : {
//																        type : 'api',
//																        url : 'rest/api/tree/sec'
//															        }
//													
//													            })
//													
//													        })]
//													    } //组件结束
//															,
													         {
											                    columnWidth: .2,
											                    layout: 'form',
											                    border: false,
											                    items: [{
											                        //为空
											                        triggerAction: 'all',
											                        //为空
											                        //xtype: 'hidden',
											                        xtype: 'textfield',
											                        fieldLabel: '电量',
											                        name:'energy',
											                        anchor: '90%'
											                    }]
											                } //组件结束
														, //按钮开始
														   {
										                    columnWidth: .2,
										                    layout: 'form',
										                    border: false,
										                    items: [{
										                        //为空
										                        triggerAction: 'all',
										                        //为空
										                        //xtype: 'hidden',
										                        xtype: 'textfield',
										                        fieldLabel: '电价',
										                        name:'price',
										                        anchor: '90%'
										                    }]
										                } //组件结束
													, //按钮开始
													   {
									                    columnWidth: .2,
									                    layout: 'form',
									                    border: false,
									                    items: [{
									                        //为空
									                        triggerAction: 'all',
									                        //为空
									                        //xtype: 'hidden',
//									                        readOnly:true,
									                        xtype: 'textfield',
									                        labelWidth : 50,
									                        fieldLabel: '电费',
									                        name:'fee',
//									                        value:Ext.getCmp("energy").value()+Ext.getCmp("price").value(),
									                        anchor: '90%'
									                    }]
									                } //组件结束
													, //按钮开始
													  {
									                    columnWidth: .2,
									                    layout: 'form',
									                    border: false,
									                    items: [{
									                        //为空
									                        triggerAction: 'all',
									                        //xtype: 'hidden',
									                        xtype : "hidden",
									                        fieldLabel: '组织机构',
									                        name:'org',
									                        value:org,
									                        anchor: '90%'
									                    }]
									                } //组件结束
												, //按钮开始
										                {
										                    columnWidth: .1,
										                    layout: 'form',
										                    border: false,
										                    algin:'right',
										                    items: [{
										                     
										                        xtype: 'button',
										                        algin:'right',
										                        text: '删除',
										                        value: id,
										                        handler: function(obj){
										                            //删除一行
										                        	obj.ownerCt.ownerCt.ownerCt.remove(this.ownerCt.ownerCt, false);
										                             
										                        }
										                    }]
										                } //按钮结束
										]
										                //column布局控件结束
										            
										            });
										           
										            //添加fieldSet
										            simple1.add(org_fieldSet);
										        },
										        iconCls: 'blist'
								    	  	}
									
										,
									       {  
												columnWidth: .2,
												margin:'20px',
												fieldLabel:'',
									            xtype:'displayfield',  
									            value:Ext.util.Format.date(new Date(),"Y"+"年"+"m"+"月"+"d"+"日")
									            
									        }
									        ]
	       },
	       {
			  xtype:"xform",
			  scrollable:true
			 
		   }
	       
			]

	
	,
    doStandard: function(data){
        var json = {};
        for(var p in data){
            var idx = p.indexOf('.');
            if(idx != -1){   //如果属性名称包含.进行对象层次分隔
                this.process(data[ p ], p, json);
            } else {
                json[ p ] = data[ p ];
            }
        }
        return json;        
    }

	
});
